#
# Linux 2.6 Kbuild file for common modules
# NB: HAL is build seperately
#

ifeq ($(obj),)
obj := .
endif

DEPTH := ..

#include $(obj)/Makefile.inc
HOST_CMN_CONVG_SRC := $(DEPTH)/cmn_dev

ifeq ($(strip ${QCA_PARTNER_MAKE_F_SUPPORT}),1)
export QCA_PARTNER_MAKE_F_INC=1
endif
include $(obj)/$(DEPTH)/os/linux/Makefile-linux.common

INCS += -I$(obj)/$(DEPTH)/include -I$(obj)/$(DEPTH)/umac/include \
        -I$(obj)/$(DEPTH)/umac/if_lmac -I$(obj)/$(DEPTH)/umac/crypto \
        -I$(obj)/$(DEPTH)/umac/scan -I$(obj)/$(DEPTH)/umac/resmgr \
        -I$(obj)/$(DEPTH)/umac/pm -I$(obj)/$(DEPTH)/umac/txrx \
        -I$(obj)/$(DEPTH)/umac/acs -I$(obj)/$(DEPTH)/umac/txbf \
        -I$(obj)/$(DEPTH)/umac/wnm -I$(obj)/$(DEPTH)/umac/dfs \
        -I$(obj)/$(DEPTH)/umac/wifipos \
        -I$(obj)/$(DEPTH)/umac/rtt \
        -I$(obj)/$(DEPTH)/umac/wds -I$(obj)/$(DEPTH)/umac/ique \
        -I$(obj)/$(DEPTH)/hal -I$(obj)/$(DEPTH)/lmac/ath_dev \
        -I$(obj)/$(DEPTH)/lmac/dfs \
        -I$(obj)/$(DEPTH)/hal/$(OS) \
        -I$(obj)/$(DEPTH)/umac/aow  \
        -I$(obj)/$(DEPTH)/umac/vi_dbg \
        -I$(obj)/$(DEPTH)/umac/smart_antenna \
        -I$(obj)/$(DEPTH)/umac/smart_ant \
        -I$(obj)/$(DEPTH)/umac/ald \
        -I$(obj)/$(DEPTH)/cmn_dev/wmi \
        -I$(obj)/$(DEPTH)/lmac/ath_pktlog \
        -I$(obj)/$(DEPTH)/cmn_dev/wmi/inc \
        -I$(obj)/$(DEPTH)/lmac/ratectrl \
        -I$(obj)/$(DEPTH)/os/linux/mem/ \
	-I$(obj)/$(DEPTH)/umac/base \
	-I$(obj)/$(DEPTH)/cmn_dev/qdf/inc \
	-I$(obj)/$(DEPTH)/cmn_dev/qdf/linux/src \
	-I$(obj)/$(DEPTH)/cmn_dev/hif \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/inc \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/src \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/src/ce \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/src/pcie \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/src/snoc \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/src/dispatcher \
	-I$(obj)/$(DEPTH)/cmn_dev/hif/src/icnss_stub \
	-I$(obj)/$(HOST_CMN_CONVG_SRC)/htc \
	-I$(obj)/$(DEPTH)/qca_ol

obj-m += umac.o

OSDEP_SRC := $(DEPTH)/os/linux/src


ifeq ($(strip $(BUSNAME)),usb)
BUS_OBJ = $(OSDEP_SRC)/usb_eth.o
endif

ifeq ($(strip $(BUSNAME)),gmac)
BUS_OBJ = $(OSDEP_SRC)/if_ath_gmac.o
endif


ifneq ($(strip $(UMAC_SUPPORT_APONLY)),0)
OSDEP_OBJS := $(BUS_OBJ) $(OSDEP_SRC)/ieee80211_wireless.o $(OSDEP_SRC)/osif_umac.o $(OSDEP_SRC)/if_media.o
else
OSDEP_OBJS := $(BUS_OBJ) $(OSDEP_SRC)/ieee80211_wireless.o $(OSDEP_SRC)/osif_umac.o $(OSDEP_SRC)/if_media.o
endif

ifeq ($(QCA_NSS_PLATFORM), 1)
OSDEP_OBJS +=$(OSDEP_SRC)/osif_nss.o
endif

OSDEP_OBJS +=$(OSDEP_SRC)/osif_fs.o
OSDEP_OBJS +=$(OSDEP_SRC)/osif_net.o
OSDEP_OBJS +=$(OSDEP_SRC)/osif_net_event.o


ifeq ($(BUILD_QDF_NET_IOCTL),1)
EXTRA_CFLAGS+= -DQDF_NET_IOCTL_SUPPORT
OSDEP_OBJS +=$(OSDEP_SRC)/osif_net_ioctl.o
OSDEP_OBJS +=$(OSDEP_SRC)/osif_net_wext.o
endif

ifeq ($(HOST_SW_LRO_ENABLE), 1)
OSDEP_OBJS += $(OSDEP_SRC)/ath_lro.o
endif

ifeq ($(ATH_BAND_STEERING), 1)
OSDEP_OBJS += $(OSDEP_SRC)/ath_band_steering.o
OSDEP_OBJS += $(OSDEP_SRC)/ath_lowi_if.o
endif

ifeq ($(ATH_SSID_STEERING),1)
OSDEP_OBJS += $(OSDEP_SRC)/ath_ssid_steering.o
endif

ifeq ($(ATH_PARAMETER_API),1)
OSDEP_OBJS += $(OSDEP_SRC)/ath_papi.o
endif

ifeq ($(QCA_AIRTIME_FAIRNESS), 1)
OSDEP_OBJS += airtime_fairness/airtime_fairness_directattach.o
endif

ifeq ($(UMAC_SUPPORT_ACFG), 1)
OSDEP_OBJS += $(OSDEP_SRC)/ieee80211_ioctl_acfg.o
OSDEP_OBJS += $(OSDEP_SRC)/acfg_net_event.o
endif

ifeq ($(ATH_SUPPORT_VLAN), 1)
OSDEP_OBJS +=  $(OSDEP_SRC)/adf_net_vlan.o
endif

ifeq ($(ATH_SUPPORT_WRAP), 1)
OSDEP_OBJS +=  $(OSDEP_SRC)/osif_wrap.o
endif

ifeq ($(ATH_SUPPORT_LINUX_VENDOR), 1)
OSDEP_OBJS += $(OSDEP_OBJS_VENDOR)
endif

ifeq ($(ATH_RXBUF_RECYCLE), 1)
OSDEP_OBJS += $(OSDEP_SRC)/ath_skbrecycle.o
endif

ifeq ($(ATH_SUPPORT_HYFI_ENHANCEMENTS), 1)
OSDEP_OBJS += $(OSDEP_SRC)/ald_netlink.o
endif

OSDEP_OBJS += $(OSDEP_SRC)/ext_ioctl_drv_if.o

ifeq ($(QCA_THIRDPARTY), 1)
PLTFRM_OBJS = $(DEPTH)/thirdparty/$(THIRDPARTY_VENDOR)/ath_carr_pltfrm.o
endif


ifeq ($(ATH_PERF_PWR_OFFLOAD), 1)

HOST_CMN_CONVG_HIF_SRC := $(DEPTH)/cmn_dev/hif/src
HOST_CMN_CONVG_HIF_INC1 := $(DEPTH)/cmn_dev/hif
HOST_CMN_CONVG_HTC_INC := $(DEPTH)/cmn_dev/htc

ifeq ($(BUILD_X86), y)
ifeq ($(QCA_THIRDPARTY), 1)
PERF_PWR_OFFLOAD_SRC := $(DEPTH)/$(FIRMWARE_REL_PATH)
else
PERF_PWR_OFFLOAD_SRC := $(DEPTH)/offload
endif
else
PERF_PWR_OFFLOAD_SRC := $(DEPTH)/$(FIRMWARE_REL_PATH)
endif
PERF_PWR_OFFLOAD_WMI_SRC := $(DEPTH)/cmn_dev/wmi
PERF_PWR_OFFLOAD_REGDMN_SRC := $(PERF_PWR_OFFLOAD_SRC)/wlan/regdmn

PERF_PWR_OFFLOAD_INC := -I$(PERF_PWR_OFFLOAD_DIR_PATH)/wlan/include \
            -I$(PERF_PWR_OFFLOAD_DIR_PATH)/wlan/ath_pktlog/include \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/htt/include \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/wlan/txrx/include \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/include \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/include \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/hif/pci \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/hif/pci/linux   \
			-I$(PERF_PWR_OFFLOAD_DIR_PATH)/os/linux/include \
            -I$(PERF_PWR_OFFLOAD_DIR_PATH)/wlan/regdmn \
            -I$(PERF_PWR_OFFLOAD_DIR_PATH)/wlan/lmac_offload_if


ifeq ($(ATH_TGT_TYPE),AR9888)
# We build the host driver against the v1 headers - the registers that the host driver
# uses had better be compatible across v1/v2
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include
#PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR9888/v1/extra/hw
#PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR9888/v1/extra/
#PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR9888/v1
endif



ifeq ($(ATH_TGT_TYPE),AR6320)
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR6320/extra/hw
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR6320/extra/
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR6320
endif


ifeq ($(ATH_TGT_TYPE),AR6004)
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR6004/hw
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR6004
endif


ifeq ($(ATH_TGT_TYPE),AR900B)
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include
#PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR900B/extra/hw
#PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR900B/extra/
#PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/include/AR900B
endif
PERF_PWR_OFFLOAD_INC += -I$(PERF_PWR_OFFLOAD_DIR_PATH)/hw/include



INCS += $(PERF_PWR_OFFLOAD_INC)

ifneq ($(strip $(REMOVE_PKT_LOG)),1)
PERF_PWR_OFFLOAD_OBJS += $(PKTLOG_AC_OBJS)
endif #REMOVE_PKT_LOG

endif #end perf_pwr_offload

ifeq ($(TARGET),ANDROID)
COPTS += -Wframe-larger-than=4096
endif

ifeq ($(TARGET),i386-elf)
COPTS += -Wframe-larger-than=1190
endif #x86 stack frame limit

ifeq ($(TARGET),armv4-le-elf)
COPTS += -Wframe-larger-than=1190
endif #arm stack frame limit


EXTRA_CFLAGS+= $(INCS) $(COPTS) -Wno-unused-function

ifeq ($(strip ${QCA_PARTNER_MAKE_F_SUPPORT}),1)
EXTRA_CFLAGS+= -DKBUILD_MODNAME=\"umac\"
MOD_CFLAGS = -D"KBUILD_STR(s)=\#s" -D"KBUILD_BASENAME=KBUILD_STR(umac.mod)"  -D"KBUILD_MODNAME=KBUILD_STR(umac)"
endif

umac-objs := base/ieee80211_ucfg.o \
             base/ieee80211_rate_estimate.o \
             base/ieee80211_channel.o base/ieee80211_common.o base/ieee80211_config.o \
             base/ieee80211_node.o base/ieee80211_node_ap.o base/ieee80211_node_sta.o \
             base/ieee80211_node_ibss.o base/ieee80211_rateset.o base/ieee80211_vap.o \
             base/ieee80211_msg.o base/ieee80211_tsftimer.o base/ieee80211_vap_ath_info.o \
             crypto/ieee80211_crypto.o crypto/ieee80211_crypto_ccmp.o crypto/aes-gcm.o\
             crypto/ieee80211_crypto_ccmp_sw.o crypto/ieee80211_crypto_pmf.o \
             crypto/ieee80211_crypto_none.o crypto/ieee80211_crypto_tkip.o \
             crypto/ieee80211_crypto_tkip_sw.o \
             crypto/ieee80211_crypto_wep.o crypto/ieee80211_rsn.o \
             crypto/ieee80211_crypto_rijndael.o crypto/ieee80211_wps.o \
             crypto/ieee80211_wapi.o crypto/ieee80211_crypto_wpi_sms4.o \
             crypto/ieee80211_crypto_wep_mbssid.o \
             mlme/ieee80211_beacon.o mlme/ieee80211_ie.o mlme/ieee80211_mgmt.o \
             mlme/ieee80211_mgmt_ap.o mlme/ieee80211_mgmt_sta.o mlme/ieee80211_mlme.o mlme/ieee80211_proto.o \
             mlme/ieee80211_mlme_ap.o mlme/ieee80211_mlme_sta.o mlme/ieee80211_mlme_ibss.o  \
             mlme/ieee80211_mgmt_ibss.o  mlme/ieee80211_mgmt_bss.o mlme/ieee80211_mlme_sw_bmiss.o \
             mlme/ieee80211_mlme_app_ie.o  mlme/ieee80211_ie_utils.o \
             mlme/ieee80211_bssload.o \
             pm/ieee80211_ap_power.o pm/ieee80211_power.o pm/ieee80211_sta_power.o \
             pm/ieee80211_power_queue.o \
             regdmn/ieee80211_regdmn.o resmgr/ieee80211_resmgr.o resmgr/ieee80211_resmgr_sm.o \
             resmgr/ieee80211_resmgr_oc_scheduler.o \
             scan/ieee80211_scan.o scan/ieee80211_scan_api.o scan/ieee80211_aplist.o scan/ieee80211_scanentry.o \
             network_listner/ieee80211_nl.o \
             acs/ieee80211_acs.o \
             cbs/ieee80211_cbs.o \
             acl/ieee80211_acl.o \
             dfs/ieee80211_csa.o \
             dfs/ieee80211_dfs.o \
             wds/ieee80211_wds.o \
             txbf/ieee80211_txbf.o \
             sme/ieee80211_sm.o sme/ieee80211_assoc_sm.o \
             sme/ieee80211_connection_sm.o sme/ieee80211_ibss_sm.o \
             txrx/ieee80211_input.o txrx/ieee80211_output.o txrx/ieee80211_frag.o $(OSDEP_OBJS) $(PLTFRM_OBJS) \
             ique/ieee80211_me.o ique/ieee80211_hbr.o base/ieee80211_vap_pause.o \
             admctl/ieee80211_admctl.o admctl/ieee80211_admctl_ap.o \
             wnm/ieee80211_wnm.o wnm/ieee80211_wnm_ap.o wnm/ieee80211_wnm_sta.o\
             vi_dbg/ieee80211_vi_dbg.o \
             base/ieee80211_node_proxyarp.o $(OSDEP_SRC)/osif_proxyarp.o \
             smart_ant/ieee80211_smart_ant_api.o \
             $(OSDEP_SRC)/ath_wbuf.o \
             $(OSDEP_SRC)/ath_timer.o \
             $(OSDEP_SRC)/ath_green_ap.o \
             $(OSDEP_SRC)/ath_netlink.o \
             $(OSDEP_SRC)/umac_exports.o

ifeq ($(UMAC_SUPPORT_FILS), 1)
umac-objs += crypto/ieee80211_crypto_fils.o crypto/aes-siv.o crypto/aes-omac1.o crypto/aes-ctr.o
endif

ifeq ($(ATH_SUPPORT_WIFIPOS), 1)
umac-objs += wifipos/ieee80211_wifipos.o
endif

umac-objs += $(OSDEP_SRC)/if_bus.o

ifeq ($(strip ${BUS}),AHB)
umac-objs += $(OSDEP_SRC)/ath_ahb.o
endif

ifeq ($(strip ${BUS}),PCI)
umac-objs += $(OSDEP_SRC)/ath_pci.o
endif

ifeq ($(strip ${BUS}),dual)
umac-objs += $(OSDEP_SRC)/ath_ahb.o
umac-objs += $(OSDEP_SRC)/ath_pci.o
endif

ifeq ($(ATH_SUPPORT_LOWI),1)
umac-objs += rtt/ieee80211_rtt.o
endif

ifeq ($(UMAC_SUPPORT_RRM), 1)
umac-objs += rrm/ieee80211_rrm.o rrm/ieee80211_rrm_ie.o rrm/ieee80211_rrm_ap.o rrm/ieee80211_rrm_sta.o rrm/ieee80211_rrm_misc.o
endif


ifeq ($(ATH_BAND_STEERING), 1)
umac-objs +=band_steering/band_steering.o band_steering/band_steering_direct_attach.o
endif

ifeq ($(ATH_PARAMETER_API),1)
umac-objs +=papi/papi.o
endif

ifeq ($(ATH_SUPPORT_MBO), 1)
umac-objs +=mbo/ieee80211_mbo.o
endif

ifeq ($(QCN_IE), 1)
umac-objs +=qcn/qcn.o
endif


ifeq ($(UMAC_SUPPORT_QUIET), 1)
umac-objs +=  \
             mlme/ieee80211_quiet.o
endif

umac-objs += $(OSDEP_SRC)/osif_mon.o


ifeq ($(strip ${ATH_SUPPORT_P2P}),1)
umac-objs +=  p2p/ieee80211_notify_tx_bcn.o p2p/ieee80211_p2p_client.o \
              p2p/ieee80211_p2p_client_power.o \
              p2p/ieee80211_p2p_device.o p2p/ieee80211_p2p_go.o \
              p2p/ieee80211_p2p_go_schedule.o p2p/ieee80211_p2p_ie.o \
              p2p/ieee80211_p2p_kernel.o p2p/ieee80211_p2p_go_power.o \
              p2p/ieee80211_p2p_prot_go.o p2p/ieee80211_p2p_prot.o \
              p2p/ieee80211_p2p_prot_client.o p2p/ieee80211_p2p_prot_utils.o
INCS += -I$(obj)/$(DEPTH)/umac/p2p
endif


ifeq ($(ATH_EXT_AP), 1)
umac-objs += extap/ieee80211_mitbl.o extap/ieee80211_extap.o
endif

ifeq ($(ATH_SUPPORT_HYFI_ENHANCEMENTS), 1)
umac-objs += ald/ieee80211_ald.o
endif

clean-files := modules.order

ifeq ($(strip ${QCA_PARTNER_MAKE_F_SUPPORT}),1)
all: umac.ko

umac.mod.o: umac.mod.c
	${CC} -c -o $@ ${EXTRA_CFLAGS} ${MOD_CFLAGS} $<

umac.o: ${umac-objs}
	$(LD) -m elf32btsmip -r -o umac.o $(umac-objs)
	$(KERNELPATH)/scripts/mod/modpost umac.o

umac.ko: umac.o umac.mod.o
	$(LD) $(LDOPTS) -o umac.ko umac.o umac.mod.o

%.o: %.c
	${CC} -c -o $@ ${EXTRA_CFLAGS} $<
endif
